package com.homelock.thread;

import com.homelock.common.config.IotRegisterLockConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class LockRegisterAsyncTask {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    IotRegisterLockConfig iotRegisterLockConfig;

    /**
     * 异步注册门锁
     * 缓存重发undo
     * @param imei
     * @param devId
     * @throws
     */
    @Async("asyncTaskExecute")
    public void runRegisterLockTask(String imei,String devId,Long sourceId)  {
        logger.info("进入【runRegisterLockTask】的线程:【{}】执行中，开始进行注册操作",Thread.currentThread().getName());
        logger.info("本地门锁新增成功，向IOT平台 注册门锁：{}，{}",imei,devId);
        iotRegisterLockConfig.requestForLockRegister(imei,devId,sourceId);
    }
}
